$(document).ready(function() {	
	$.cookie('AUTOLOAD_NEWS', 1);
	$(window).scroll(function(){			
		if  ($(window).scrollTop() == $(document).height() - $(window).height()){
			loadNews();
		}
	}); 
});
function loadNews() {	
	var intPage 	= $('#ppage').val();	
	var intCate		= $('#cat').val();	
	var intSub		= $('#sub').val();
	var intFi		= $('#fi').val();	
	var intOrd		= $('#ord').val();
	if($.cookie('AUTOLOAD_NEWS') == 1 && intPage > 0) {		
		$.cookie('AUTOLOAD_NEWS',0);	
		$('.boxNews .loading').show();
		$.getJSON(				
			HOST_VFRIEND + 'ajax/news?act=5&page='+intPage+'&fi='+intFi+'&ord='+intOrd+'&cat='+intCate+'&sub='+intSub+'&callback=?',		
			function(response) {	
				var msg 	= response['msg'];
				var error	= response['error'];
				if(error == 0) {
					$('#ppage').remove();
					$('.boxNews .loading').remove();					
					$('.boxNews ul').append(response['dnews']);
				} else {
					alert(msg);
				}
				$.cookie('AUTOLOAD_NEWS', 1);
			}
		);
	}
}